
package controller;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;

import view.View;

public class Main {
	
	public static final int nSimuations = 100000;
	
	public Main(){
	}

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		
		final String[][] parameters = Main.load_data();
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
		      public void run() {
		  		 try {
					@SuppressWarnings("unused")
					View view = new View(parameters);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		      }
		    });


	}
	/**
	 * read a csv file 
	 * @return the parameters loaded from the file
	 * @throws IOException
	 */
	public static String[][] load_data() throws IOException
	{
		
		final BufferedReader reader = new BufferedReader(
				new FileReader(new File("stocks.csv")));
		
		// discard header
		String data = reader.readLine();
		
		String [][] returnvalue = new String[data.split(";").length][5];
		// we just want 5 lines
		for (int j=0;j<5;j++)
		{
			//read one line
			data = reader.readLine();
			String[] dataItems = data.split(";");
			// we store each attributes
			for (int i=0 ; i<dataItems.length ; i++)
				returnvalue[i][j] = new String(dataItems[i]);
			
		}
			
		reader.close();
		return returnvalue;
		
	}

}
